gh-153506: Guard IDLE completions against a non-iterable __all__#153507
Open
tonghuaroot wants to merge 1 commit into
Open
gh-153506: Guard IDLE completions against a non-iterable __all__#153507tonghuaroot wants to merge 1 commit into
tonghuaroot wants to merge 1 commit into
Conversation
The ATTRS empty-prefix branch of autocomplete.fetch_completions() evaluated __main__.__all__ without a guard, while the non-empty sibling branch already caught failures, so a non-iterable __all__ in the interactive namespace raised TypeError on Tab. Catch the failure and return empty completion lists instead, leaving the sibling branch untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
autocomplete.AutoComplete.fetch_completionsevaluated__main__.__all__in the ATTRS empty-prefix branch withsorted(eval("__all__", namespace))and no guard, while the sibling non-empty-prefix branch already wrapped the equivalentsorted(entity.__all__)intry/exceptand returned empty lists on failure. A non-iterable__all__in the interactive namespace (for example__all__ = None) therefore raisedTypeErroron Tab at an empty prefix instead of showing completions.This guards the empty-prefix branch the same way, returning empty completion lists when
__all__cannot be evaluated or sorted, and leaves the sibling branch untouched. A regression test drivesfetch_completionswith a patched__main__.__all__and asserts empty lists, and that a valid namespace still yields completions.